<?php /*Template Name: Portfolio - Standard*/ ?>

<?php get_header(); ?>

<div class="cols">
    <div class="col_2-3 cont_holder">
        <?php
        $defaults = array(
            'list'          => array(),
            'ppp'           => '',
            'orderby'       => 'date',
            'order'         => 'DESC'
        );
        $options = get_post_meta( get_the_ID(), 'dt_portfolio_layout', true );
        $options = wp_parse_args( $options, $defaults );

        if( !$paged = get_query_var('paged') )
            $paged = get_query_var('page');
                                
        $args = array(
            'post_type'	    => 'dt_portfolio',
            'paged'		    => $paged,
            'orderby'       => $options['orderby'],
            'order'         => $options['order'],
            'post_status'   => 'publish'
        );
                                        
        if( !empty($options['ppp']) ){
            $args['posts_per_page'] = $options['ppp'];
            unset($options['ppp']);
        }
                        
        if( $options['list'] ) {
            $args['tax_query'] = array(	
                array(
                    'taxonomy'	=> 'dt_portfolio_category',
                    'field'		=> 'id',
                    'terms'		=> current( $options['list'] ),
                    'operator' 	=> ( 'only' == key($options['list']) )?'IN':'NOT IN',
                )
            );
        }

        $wp_query = new Wp_Query( $args );
        ?>
        
        <?php if( post_password_required() ): ?>    
    
            <div class="cols">
            
                <?php echo get_the_password_form(); ?>

            </div>
        
        <?php elseif( have_posts() ): ?>

            <?php while( have_posts() ): the_post(); ?>
                <?php get_template_part('dt_portfolio_index', 'content'); ?>
            <?php endwhile; ?>
            
            <?php 
            if( function_exists('wp_pagenavi') ) {
                wp_pagenavi( '<div class="paginator inblog">', '</div>', 'pages');
            }else {
                $args = array(
                    'before'        => '<div class="paginator inblog"><div class="pages">',
                    'after'         => '</div></div>',
                    'pagelink'      => '<span>%</span>'
                );
                wp_link_pages( $args );
            }
            ?>
        
        <?php else:?>

            <p><?php _e( 'Sorry, but page is empty.', LANGUAGE_ZONE ); ?></p>
            
        <?php endif; ?>
    </div>
    
    <?php wp_reset_query(); ?>
    
    <?php dt_get_where_filter_params( 'portfolio-index' ); ?>
    <?php get_sidebar(); ?>

</div>

<?php get_footer(); ?>